<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>获奖情况</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../../../layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../../layuiadmin/style/admin.css" media="all">
    <style>
        .layui-form-label {
            width: 120px;
        }

        .layui-form-label2 {
            padding-top: 0px;
            padding-bottom: 0px;
        }

        .layui-input-block {
            margin-left: 150px;
        }
    </style>
</head>
<body>


<div class="layui-fluid">
    <div class="layui-row layui-col-space15">

        <div class="layui-col-md12">
            <div class="layui-card">

                <div class="layui-card-header">获奖情况</div>
                <div class="layui-card-body">


                    <div class="test-table-reload-btn" style="margin-bottom: 10px;">
                        获奖名称：
                        <div class="layui-inline">
                            <input class="layui-input" name="name" id="name" autocomplete="off">
                        </div>
                        评奖单位：
                        <div class="layui-inline">
                            <input class="layui-input" name="college" id="college" autocomplete="off">
                        </div>
                        <button class="layui-btn" data-type="reload">查询</button>
                        <button class="layui-btn" id="add_btn">添加</button>
                    </div>

                    <table class="layui-hide" id="table_award" lay-filter="table"></table>


                </div>
            </div>
        </div>
    </div>
</div>
<script src="../../../layuiadmin/layui/layui.js"></script>
</body>
<div class="layui-fluid layui-hide" id="add_form">
    <div class="layui-card">
        <form class="layui-form" action="" lay-filter="component-form-group">
            <div class="layui-col-xs6 layui-col-md12">
                <form class="layui-form" action="" lay-filter="component-form-group">
                    <div class="layui-form-item">
                        <div class="layui-col-md6">
                            <label class="layui-form-label">获奖名称</label>
                            <div class="layui-input-block">
                                <input type="text" name="number" lay-verify="required|number"
                                       autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-col-md6">
                            <label class="layui-form-label">评奖单位</label>
                            <div class="layui-input-block">
                                <input type="text" name="date" lay-verify="date" autocomplete="off"
                                       class="layui-input" lay-key="1">
                            </div>
                        </div>

                    </div>

                    <div class="layui-form-item">
                        <div class="layui-col-md6">
                            <label class="layui-form-label">年份</label>
                            <div class="layui-input-block">
                                <input type="text" name="number" lay-verify="required|number"
                                       autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-col-md6">
                            <label class="layui-form-label">备注</label>
                            <div class="layui-input-block">
                                <input type="text" name="date" lay-verify="date" autocomplete="off"
                                       class="layui-input" lay-key="1">
                            </div>
                        </div>

                    </div>


                    <div class="layui-form-item">
                        <label class="layui-form-label">附件</label>
                        <div class="layui-input-block">
                            <div class="layui-upload-drag" id="upload" style="padding:78px 20px;width: 130px;">
                                <i class="layui-icon"></i>
                                <p>点击上传，或将文件拖拽到此处</p>
                            </div>
                        </div>
                    </div>
                    <!--<div class="layui-form-item layui-layout-admin">-->
                    <!--<div class="layui-input-block">-->
                    <!--<div class="layui-footer" style="left: 0;">-->
                    <!--<button class="layui-btn" lay-submit="" lay-filter="component-form-demo1">立即提交</button>-->
                    <!--<button type="reset" class="layui-btn layui-btn-primary">重置</button>-->
                    <!--</div>-->
                    <!--</div>-->
                    <!--</div>-->
                </form>
            </div>

        </form>
    </div>
</div>
<script type="text/html" id="file_bar">
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看</a>
</script>
<script type="text/html" id="op_bar">
    <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
<script>
    layui.config({
        base: '../../../layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'layer', 'table','upload'], function () { //独立版的layer无需执行这一句
        var $ = layui.jquery, layer = layui.layer; //独立版的layer无需执行这一句
        var table = layui.table, upload = layui.upload;
        //拖拽上传
        upload.render({
            elem: '#upload'
            , url: '/upload/'
            , done: function (res) {
                console.log(res)
            }
        });
        //监听工具条
        table.on('tool(table)', function(obj){
            var data = obj.data;
            if(obj.event === 'detail'){
                layer.msg('ID：'+ data.id + ' 的查看操作');
            } else if(obj.event === 'del'){
                layer.confirm('真的删除行么', function(index){
                    obj.del();
                    layer.close(index);
                });
            } else if(obj.event === 'edit'){
                layer.alert('编辑行：<br>'+ JSON.stringify(data))
            }
        });
        function Award() {
            this.init();
        }

        Award.prototype = {
            //方法级渲染
            initTable: function () {
                table.render({
                    elem: '#table_award'
                    , url: layui.setter.base + 'json/table/user.js'
                    , cellMinWidth: 80
                    , cols: [[
                        {field: 'username', title: '获奖名称'}
                        , {field: 'sex', title: '评奖单位'}
                        , {field: 'city', title: '年份'}
                        , {field: 'classify', title: '备注'}
                        , {field: 'classify', title: '附件',toolbar: '#file_bar'}
                        , {field: 'classify', title: '操作',toolbar: '#op_bar'}
                    ]]
                    , page: true
                });
            },
            add: function () {
                var add_form = $('#add_form');
                layer.open({
                    type: 1
                    ,title:'添加'
                    , id: 'addDiv' //防止重复弹出
                    , content: add_form
                    , shade: 0.8
                    , area: ['800px', '600px']
                    , maxmin: true
                    , btn: ['保存', '返回']
                    , btnAlign: 'c' //按钮居中
                    , success: function (layero, index) {
                        add_form.removeClass('layui-hide');
                    }
                    , end: function (layero, index) {
                        add_form.addClass('layui-hide');
                    }
                    , yes: function () {
                        layer.closeAll();
                    }
                    , btn2: function (index, layero) {
                        layer.closeAll();
                    }
                });
            },
            init: function () {
                this.initTable();
                $('#add_btn').click(function () {
                    award.add();
                })
            }
        }

        var award = new Award();


    });
</script>
</html>